//
// Created by work on 24-6-6.
//

#ifndef IOT_PLAT_CRTMODELYXINFO_H
#define IOT_PLAT_CRTMODELYXINFO_H

#include <iot_model_device/CRtModelSigBase.h>
#include <os/miscellany/CConfigs.h>
#include <os/miscellany/CValue.h>
namespace iotplat {
    class CRtModelYxInfo : public CRtModelSigBase{
    public:
        enum EModelYxCol {
            EValues = 7
        };

        struct SYxValue {
            int value = 0;
            std::string v_descr;
            Json::Value v_image;
            Json::Value toJson()const {
                Json::Value obj;
                obj["value"] = value;
                obj["v_descr"] = v_descr;
                obj["v_image"] = v_image;
                return obj;
            }

            void fromJson(Json::Value obj) {
                value = obj["value"].asInt();
                v_descr = obj["v_descr"].asString();
                v_image = obj["v_image"];
            }
        };


        std::vector<SYxValue> values;
        static std::map<EModelYxCol, std::string> rtModelYxColToStringMap;
        static std::map<EModelYxCol, CValue::EValueType> rtYxDataTypeByField;

    public:
        explicit CRtModelYxInfo();
        Json::Value toJson();
        Json::Value valuesToJson()const;
        void valuesFromJson(const Json::Value &json);
        void fromJson(Json::Value  json);
    };
    static const char* t_yx_name = "t_model_yx";
} // iotplat

#define YX_ENUM CRtModelYxInfo::EModelYxCol
#define yxFieldName(type)           CRtModelYxInfo::rtModelYxColToStringMap.find(type)->second
#define yxDataTypeByField(type)     CRtModelYxInfo::rtYxDataTypeByField.find(type)->second

#endif //IOT_PLAT_CRTMODELYXINFO_H
